public final class ai extends az
        implements k {

    private static final az b[] = new az[0];
    private az f[];
    public int a;
    private o g;
    private aj h;
    private ba i;

    public ai(o o1, o o2) {
        super(o1, o1.r, "");
        f = b;
        i = null;
        g = o2;
    }

    public final int g_() {
        return f.length;
    }

    public final ba a(int j) {
        return f[j];
    }

    private void d() {
        if (g_() > 0) {
            a(f[a].d);
        } else {
            a("");
        }
    }

    public final void a(cc cc1, int j) {
        int l;
        az aaz[] = new az[l = cc1.a];
        while (--l >= 0)
            aaz[l] = (az) cc1.a(l);
        a(aaz, j);
    }

    private void a(az aaz[], int j) {
        f = aaz;
        a(j, true, false);
    }

    public final void a(int j, boolean flag, boolean flag1) {
        int l = g_();
        if (j >= l)
            j = l - 1;
        if (j < 0)
            j = 0;
        if (flag || a != j) {
            a = j;
            d();
            A();
            if (flag1)
                bh.b().a(this, -3);
        }
    }

    private boolean b(int j) {
        aj aj1 = h;
        int l = g_();
        ba ba1;
        if ((ba1 = aj1.b) == null)
            return false;
        if (ba1 != i) {
            i = ba1;
            return false;
        }
        int i1;
        if ((i1 = (i1 = d(ba1)) + j) < 0)
            i1 = l - 1;
        else if (i1 >= l)
            i1 = 0;
        else
            return false;
        ba ba2;
        if ((ba2 = a(i1)).F()) {
            aj1.a(ba2, 6);
            i = ba2;
            return true;
        } else {
            return false;
        }
    }

    public final boolean a(int j, int l) {
        boolean flag = false;
        if (h == null) {
            if (j != 2 && (l == -5 || l == 10)) {
                if (g_() > 0) {
                    ap ap1 = new ap(bh.d(), -100, 0);
                    int i1 = 0;
                    for (int j1 = g_(); i1 < j1; i1++)
                        ap1.b(a(i1).i(1));

                    i = a(a);
                    h = aj.a(ap1);
                    h.a(0).I = g;
                    h.c = this;
                    bh.b().a(h, true);
                }
                return true;
            }
        } else {
            if (j == 2) {
                if (l == -1) {
                    flag = b(-1);
                } else if (l == -2) {
                    flag = b(1);
                }
            }
        }
        return flag;
    }

    public final cd a(ba ba1) {
        return null;
    }

    public final az b(ba ba1, int j) {
        if (j == 3)
            return cd.a;
        if (j == 2)
            return cd.b;
        else
            return null;
    }

    public final boolean a(Object obj) {
        k k1;
        if ((k1 = q().c) != null)
            return k1.a(obj);
        else
            return false;
    }

    public final void a(ba ba1, int j) {
        label0:
        {
            if (j == -6)
                h.a(f[a], 1);
            if (j == 1)
                a(ba1.H.d(ba1), false, true);
            else if (j != 2)
                break label0;
            h();
        }
    }

    private void h() {
        bh.b().b(h, true);
        h = null;
        int j = 0;
        for (int l = g_(); j < l; j++)
            a(j).K.b();

    }

}